1. Field of the Invention
The present invention relates to a file system of a computer system, and particularly to a file system using a non-volatile semiconductor memory device such as a flash memory or the like.
2. Description of the Related Art
A flash memory is a type of an EEPROM (Electrically Erasable and Programmable ROM) which can be rewritten electrically, and has such characteristics that it is less expensive than a DRAM (Dynamic Random Access Memory), a backup power supply is unnecessary, the change of bits is irreversible, data is erased bank by bank, erasure of a bank requires time, and the number of bank erasures is limited.
The flash memory having such characteristics is widely used as a data storage device in equipment such as a mobile phone, a PDA (Personal Digital Assistant), a digital still camera and the like. In such equipment, varieties of data to be stored have increased, leading to frequent operations such as saving, deleting and moving of data, so that a file system operating on the flash memory is required. The flash memory has such a characteristic that the change of bits is irreversible, i.e., the change from bit 1 to 0 is possible whereas the inverse change of bit 0 to 1 is limited. This raises a problem as described below when a file system is constructed on the flash memory. Everytime the contents of a file are changed, a corresponding bank must be erased for the changed contents to be written thereto. A memory related to the present invention will be described with reference to the drawings.
FIG. 1 shows the structure of a memory related to the present invention. As shown in FIG. 1, a memory 122 includes a flash memory 200 and a RAM 300. Flash memory 200 includes thirty-one data banks 210 and one merge bank. One bank includes a hundred file blocks. RAM 300 includes one file block as a cache memory. When a rewrite command is executed for a file, data to be written into the file is written into RAM 300 which is a cache memory, and thereafter flash memory 200 is accessed for the data to be written into a prescribed file block.
Referring to FIGS. 2 to 6, the operation of the memory will be described. In the description below, it is assumed that data is written into file blocks in the order of a file block (100), a file block (210), a file block (250), a file block (300) and a file block (301). The operation proceeds in the ascending order of circled numbers in the drawings. The numbers indicated at the head of each paragraph below corresponds to each of the circled numbers.
1) The 31st bank which is a merge bank 220 is in an initial state (all bits are 1), while the first file block (100) that is the subject of writing (such a file block is hereinafter referred to as “target file block”) is copied from the first bank in data bank 210 within flash memory 200 to an entry C (0) of RAM 300.
2) The data of file block (100) that was copied to entry C (0) of RAM 300 is updated.
3) File block (100) at entry C (O) of RAM 300 is copied to the 31st bank which is merge bank 220.
4) From the first bank in data bank 210, file blocks other than file block (100) are copied to the 31st bank which is merge bank 220.
5) The first bank is erased to be in the initial state and is newly set as merge bank 220. New file blocks (100) to (199) including the updated file block (100) are stored in the 31st bank.
6) The first bank which is merge bank 220 is in the initial state, while the second target file block (210) is copied from the second bank in data bank 210 within flash memory 200 to entry C (0) of RAM 300.
7) The data of file block (210) that was copied to entry C (0) of RAM 300 is updated.
8) File block (210) at entry C (0) of RAM 300 is copied to the first bank which is merge bank 220.
9) From the second bank in data bank 210, file blocks other than file block (210) is copied to the first bank which is merge bank 220.
10) The second bank is erased to be in the initial state, and is newly set as merge bank 220. New file blocks (200) to (299) including the updated file block (210) are stored in the first bank.
11) The second bank which is merge bank 220 is in the initial state, while the third target file block (250) is copied from the second bank of data bank 210 in flash memory 200 to entry C (0) of RAM 300.
12) The data of file block (250) that was copied to entry C (0) of RAM 300 is updated.
13) File block (250) at entry C (0) of RAM 300 is copied to the second bank which is merge bank 220.
14) From the first bank in data bank 210, file blocks other than file block (250) are copied to the second bank which is merge bank 220.
15) The first bank is erased to be in the initial state, and is newly set as merge bank 220. New file blocks (200) to (299) including the updated file block (250) are stored in the second bank.
16) The first bank which is merge bank 220 is in the initial state, while the fourth target file block (300) is copied from the third bank of data bank 210 in flash memory 200 to entry C (0) of RAM 300.
17) The data of file block (300) that was copied to entry C (0) of RAM 300 is updated.
18) File block (300) at entry C (0) of RAM 300 is copied to the first bank which is merge bank 220.
19) From the third bank in data bank 210, file blocks other than file block (300) are copied to the first bank which is merge bank 220.
20) The third bank is erased to be in the initial state, and is newly set as new merge bank 220. New file blocks (300) to (399) including the updated file block (300) are stored in the first bank.
21) The third bank which is merge bank 220 is in the initial state, while the fifth target block (301) is copied from the first bank of data bank 210 in flash memory 200 to entry C (0) of RAM 300.
22) The data of file block (301) that was copied to entry C (0) of RAM 300 is updated.
23) File block (301) at entry C (0) of RAM 300 is copied to the third bank which is merge bank 220.
24) From the first bank in data bank 210, file blocks other than file block (301) are copied to the third bank which is merge bank 220.
25) The first bank is erased to be in the initial state, and is newly set as merge bank 220. New file blocks (300) to (399) including the updated file block (301) are stored in the third bank.
Thus, in order to update five file blocks, banks must be erased five times. As described earlier, a large amount of time is required for such erasure by the bank, and there is a certain limit for the number of erasures.
However, in the conventional file system, bank erasure frequently occurs, lowering operation speed and shortening lifetime of the flash memory. Moreover, in the conventional file system, if the power is shut off or reset with unexpected timing, the entire file system may be destroyed and hence become unworkable without reformat. If this happens, the stored data will be lost.